import React, { Component } from 'react'

export default class shouldcomponentupdate extends Component {
    state ={
        name:"miaohao"
    }
    shouldComponentUpdate(newprop,newstate){          //是否更新dom渲染  ，也是react中比较常见的性能优化函数
        if(JSON.stringify(this.state) === JSON.stringify(newstate))
            return false;
        else
            return true;
    }
  render() {
    return (
      <div>
        {this.state.name}
        <button onClick={()=>{
            this.setState({
                name:'walawala'
            })
        }}>
            click
        </button>
      </div>
    )
  }
}
